<template>
  <div class="tw-fixed tw-top-0 tw-left-0 width100 height100 tw-bg-[#000000] font-Regular">
    <div class="video-play-top">
      <study-video v-model="data.currentItem" :dataArr="data.ScheduleDetail"
                   :courseId="Number(data.courseId)" :orderItemId="Number(data.orderItemId)"
                   @chengStudy="chengStudy"></study-video>
    </div>
    <study-video-bottom @goQuestion="goQuestion" :currentCourse="data.currentCourse"></study-video-bottom>
  </div>
</template>

<script setup>
import studyVideo from "@/views/study/component/study-video.vue";
import {doExerciseExercise, getScheduleDetail} from "@/api/study.js";
import {onMounted, reactive} from "vue";
import {useRoute, useRouter} from 'vue-router';
import StudyVideoBottom from "@/views/study/component/study-video-bottom.vue";

const router = useRouter();
const route = useRoute();
let data = reactive({
  courseId: 0,
  orderItemId: 0,
  structId: 0,
  ScheduleDetail: [],
  currentItem: 0,
  currentCourse: {}
})
onMounted(() => {
  data.courseId = route.query.courseId
  data.orderItemId = route.query.orderItemId
  data.structId = route.query.structId
  data.currentItem = route.query.itItem
  getVideoData()
})
const getVideoData = () => {
  let dataAll = {
    "orderItemId": data.orderItemId, //子订单id
    "courseId": data.courseId, //课程id
    "sourceType": 3, //来源类型1-课程表 2-题集 3-视频播放时课程表
    "structId": data.structId, //根据id过滤出需要展示的结构,默认不传,看视频等情况需要传递
    itItem: 0
  }
  getScheduleDetail(dataAll, (res) => {
    res.data[0].isShow = true
    data.ScheduleDetail = res.data
  })
}
const chengStudy = (item) => {
  data.currentCourse = item
}
const goQuestion = (item) => {
  let allData = {
    courseId: data.courseId,
    orderItemId: data.orderItemId,
    bankId: item.type == 'question'? item.typeAssoId : item.questionId,
  }
  doExerciseExercise(allData, res => {
    window.open(res.data)
  })
}
</script>

<style lang='scss' scoped>
.video-play-top {
  height: calc(100vh - 100px);
}
</style>

